<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>vue3的数据响应原理和实现</title>
</head>
<body>
  <div id="root"></div>
  <button id="btn">年龄+1</button>
  <script src="./index.js"></script>
  <script>
    const root = document.querySelector('#root')
    const btn = document.querySelector('#btn')

    const ob = reactive({
      name: '张三',
      age: 10
    })

    let cAge = computed(() => ob.age * 2)
    effect(() => {
      root.innerHTML = `<h1>${ob.name}---${ob.age}---${cAge.value}</h1>`
    })
    btn.onclick = function () {
      ob.age += 1
    }
  </script>
</body>
</html>
